<?php
    $this->headTitle($this->enterprise->company_name_vn.': '.$this->translator('front_end_product_list'));
	$this->headScript()
        ->appendFile($this->APP_STATIC_SERVER . '/js/jquery.tools/jquery.tools.js');
    $this->headLink()
        ->appendStylesheet($this->APP_STATIC_SERVER . '/js/jquery.ui/themes/base/ui.core.css')
        ->appendStylesheet($this->APP_STATIC_SERVER . '/js/jquery.ui/themes/base/ui.resizable.css')
        ->appendStylesheet($this->APP_STATIC_SERVER . '/js/jquery.ui/themes/base/ui.dialog.css')
        ->appendStylesheet($this->APP_STATIC_SERVER . '/js/jquery.ui/themes/base/ui.theme.css');

    $this->headScript()
        ->appendFile($this->APP_STATIC_SERVER . '/js/jquery.ui/ui.core.js')
        ->appendFile($this->APP_STATIC_SERVER . '/js/jquery.ui/ui.draggable.js')
        ->appendFile($this->APP_STATIC_SERVER . '/js/jquery.ui/ui.droppable.js')
        ->appendFile($this->APP_STATIC_SERVER . '/js/jquery.ui/ui.resizable.js')
        ->appendFile($this->APP_STATIC_SERVER . '/js/jquery.ui/ui.dialog.js');		
?>
<link href="<?php echo $this->APP_STATIC_SERVER; ?>/js/jquery.lightbox/jquery.lightbox-0.5.css" media="screen" rel="stylesheet" type="text/css" />
<script src="<?php echo $this->APP_STATIC_SERVER;?>/js/jquery.lightbox/jquery.lightbox-0.5.pack.js" type="text/javascript"></script>
<style>
    .col_50{
        float:left;
        width:48%;
        padding-left:10px;
    }
    .subrow{
        padding-bottom:10px;
        display:inline-block;
        width:100%;
    }
	
    .cart table{
        width: 100%;
        border-top: 0px;
        border-bottom: 0px;
    }
    .cart .caption td{
        font-weight: bold;
        background: #BCBBB9;
    }
    .cart tr.caption:hover td{
        font-weight: bold;
        background: #BCBBB9;
    }
    .cart tbody tr:hover td{
        background: #EFEDED;
    }
    .inline_block{
        display: inline-block;
        width: 100%;
    }
    .inline_block .col_33{
        float:left;
        width:33.3%;
    }
    .inline_block .col_33 input{
        cursor: pointer;
    }
    .clear_fix{
        clear: both;
    }
    .cart_bottom{
        margin-bottom: 10px;
    }
    .cart .amount div label{
        font-weight: bold;
    }
   .tooltip {
        display:none;
        background:#BCBBB9;
        height:auto;
        width:200px;
        padding:10px;
    }
</style>
<?php
    $skin_url = $this->APP_STATIC_SERVER . '/skins/'. $this->APP_TEMPLATE . '/'. $this->APP_SKIN;
?>
<div class="grid_12">
    <div class="grid_8 alpha">
		<div id="messageDialog" style="display:none;"></div>
        <?php if(!$this->found):?>
        <?php echo $this->translator('not_found_database');?>
        <?php else:?>
        <!--sub menu -->
        <?php echo $this->widget('bizprofile','menu',array()); ?>
        <!--end sub menu -->
        <div class="subcolumns pb10">
            <div class="b_breadcrumb pb10">
                <?php
                    $arrParamProduct = array(
                        'enterprise_id' => $this->enterprise->id,
                        'enterprise_name' => Tomato_Utility_String::removeSign($this->enterprise->company_name_en, '-', true)
                    );


                    $arrParamCat = array(
                        'enterprise_id' => $this->enterprise->id,
                        'enterprise_name' => Tomato_Utility_String::removeSign($this->enterprise->company_name_en, '-', true),
                        'cat' => $this->objCategory->category_id,
                        'slug' => ($this->objCategory->slug)?$this->objCategory->slug:Tomato_Utility_String::removeSign($this->objCategory->category_admin_name, '-', true),
                    );
                ?>
                <a href="<?php echo $this->url($arrParamProduct, 'shop_product_products');?>"><?php echo $this->translator('product_list_breakcrumb');?></a> »
                <a href="<?php echo $this->url($arrParamCat, 'shop_product_products_cat');?>"><?php echo ($this->objCategory->category_content_name)?$this->objCategory->category_content_name:$this->objCategory->category_admin_name;?></a> »
                <?php echo ($this->product->product_content_name)?$this->product->product_content_name:$this->product->product_admin_name;?>
            </div>
            <?php
                $product = $this->product;

                $quantity = null;
                $coreQty = null;
                if('non_deliver_able' == $product->product_status_of_delivery){
                    $quantity = "<span style='color:red;'>".$this->translator("product_status_of_delivery_non_deliverable")."</span>";
                    $coreQty = $product->product_status_of_delivery;
                }
                elseif('please_contact' == $product->product_status_of_delivery){
                    $quantity = $this->translator("product_status_of_delivery_".$product->product_status_of_delivery);
                    $coreQty = $product->product_status_of_delivery;
                }
                else{
                    //$quantity = ($product->product_quantity)?$product->product_quantity-$this->qtyItems:"<span style='color:red;'>".$this->translator("product_status_of_delivery_non_deliverable")."</span>";
                    $quantity = ($product->product_quantity)?$product->product_quantity:"<span style='color:red;'>".$this->translator("product_status_of_delivery_non_deliverable")."</span>";
                    $coreQty = $product->product_quantity_mode;
                }
                $p_name	= ($product->product_content_name)?$product->product_content_name:$product->product_admin_name;	
                
				$strFile = $product->product_image;
				$arrImageMain = explode(',', $strFile);				
				if($arrImageMain[count($arrImageMain)-1] == null) {unset($arrImageMain[count($arrImageMain)-1]);}
				$no_image = true;
				$file = isset($arrImageMain[0])?$arrImageMain[0]:null;
				if($file){
					$path = str_replace($this->APP_STATIC_SERVER,getcwd(),$file);
					$file = Tomato_Helper_Helper::checkFile($path, $file, '_small');
					if($file) $no_image = false;
				}
            ?>
            <div>
                <div class="subcolumns_oldgecko">
                    <span class="title"><?php echo ($product->product_content_name)?$product->product_content_name:$product->product_admin_name;?></span>
                </div>
                <div class="subcolumns_oldgecko" style="padding-bottom:5px;">
                    <div class="geckol" style="padding-right:5px;">
						<?php if($product->getImage()):?>
								<img width="200" src="<?php echo $product->getImage('_small', 200);?>" class="item_img" alt="<?php echo $p_name;?>">
						<?php endif;?>						                           
                    </div>
                    <div class="geckor">
                        <div style="text-align:justify">
                            <?php echo strip_tags(Tomato_Helper_Helper::substring($product->product_content_description, 500));?>
                        </div>
                        <div>
                            <?php echo $this->translator('front_product_price');?>:
                            <strong><?php echo $product->product_price;?> <?php echo $product->product_price_currency;?></strong>
                        </div>						
						<?php if($product->product_shipping_price_1 > 0):?>
                        <div style="width:50%; float:left;">
                            <i><?php echo $this->translator('front_product_shipping_price')?></i><br />
                            <strong><?php echo $product->product_shipping_price_1;?> <?php echo $product->product_price_currency;?></strong>
                        </div>
						<?php endif;?>						
						
                        <?php if($coreQty != 'infinity'):?>
                        <div style="width:50%; float:left;">
                            <?php echo $this->translator('front_product_source')?></i><br />
                            <strong id="qtyText"><?php echo $quantity;?></strong>
                        </div>	
                        <?php endif;?>
                        
                        <?php if($coreQty != "non_deliver_able" && $coreQty != "please_contact" && ($coreQty == 'infinity' || $product->product_quantity > 0)):?>
                        <div>
                            <?php if(!$this->cart_detail):?>
                                <?php echo $this->translator('front_product_quantity');?>:
                                <input type="text" name="quantity" id="quantity" style="width:60px;"/>
                                <a title="<?php echo $this->translator('product_add_to_cart_btn')?>" href="javascript:void(0)" class="add_btn <?php if(count($this->attributes)>0) echo 'has_attr';?>">
                                    <img style="cursor:pointer;" src="<?php echo $skin_url;?>/html/images/icon-cart.png" />
                                </a>
                                <div style="color:red" id="alert_message"></div>
                            <?php endif;?>
                        </div>
                        <?php endif;?>                        
                    </div>
                </div>
            </div>
        </div>

        <!---tab-->
        <div class="subcolumns tabs pb10">
            <ul class="tabNavigation">
                <?php //if(count($this->attributes) > 0):
					$available_tab1 = 0; 
	            	if(count($this->attributes)>0):
						foreach($this->attributes as $attribute): 
		            		if(count($this->values[$attribute->attribute_type_id])>0): 
		            			$available_tab1 = 1; 
		            		endif; 
		            	endforeach; 
		            endif;
	            	if($available_tab1==1):			
				?>
                <li><a href="#tab1" class="selected"><?php echo $this->translator('product_attribute_tab');?></a></li>
                <?php endif;?>
                <?php if($product->product_content_description!=""):?>
                <li><a href="#tab2"><?php echo $this->translator('product_description_tab')?></a></li>
                <?php endif;?>
                <?php if(count($this->relatedProducts)>0):?>
                <li><a href="#tab3"><?php echo $this->translator('product_related_tab')?></a></li>
                <?php endif;?>                
                <!-- Hình sản phẩm -->
                <?php if($no_image === false):?>
                <li><a href="#tab4"><?php echo $this->translator('product_images_tab');?></a></li>
               	<?php endif;?>				
            </ul>
            <?php if(count($this->attributes) > 0):?>
            <div id="tab1" style="display: block;">
                <form action="<?php echo $this->url(array('product_id' => $this->product->product_id), 'shoppingcart_shoppingcart_add');?>" method="POST" id="proAttFrom">
                <?php foreach($this->attributes as $attribute):?>
                    <input type="hidden" value="<?php echo $attribute->attribute_type_id;?>" name="attribute_type_id[]" />
                    <?php
                        /**
                        * Value to view
                        **/
                        $values = (count($this->values[$attribute->attribute_type_id])>0)?$this->values[$attribute->attribute_type_id]:null;
                        /**
                        * Check to checked
                        **/
                        $arrAttValue = isset($this->arrAttValue[$attribute->attribute_type_id])?$this->arrAttValue[$attribute->attribute_type_id]:null;						
                    ?>
                    <?php if($values):?>
                    <ul style="width:30%; float:left; padding-left:10px;">
                        <b><?php echo ($attribute->attribute_type_content_name)?$attribute->attribute_type_content_name:$attribute->attribute_type_admin_name;?></b>
                        <?php $ii=1; foreach($values as $value):?>
                        <li>
							<?php 	
								$img_url = (empty($value->value_type_icon)) ? "" : $value->value_type_icon;
								$file = $img_url;
								$path = str_replace($this->APP_STATIC_SERVER,getcwd(),$file);
								$file = Tomato_Helper_Helper::checkFile($path, $file, '_small');
								$img_url = $file?$file:null; 	 							
							?>
                            <input <?php if($arrAttValue == $value->value_type_id):?>checked<?php elseif($ii == 1):?>checked<?php endif;?> type="radio" name="att_value_<?php echo $attribute->attribute_type_id;?>" value="<?php echo $value->value_type_id?>" />
                            <span style="cursor: pointer;"  class="view_detail_<?php echo $value->value_type_id;?>"><?php echo ($value->value_content_name)?$value->value_content_name:$value->value_type_name;?><?php echo ($value->value_type_price > 0)?'('.$value->value_type_price.' '.$product->product_price_currency.')':null;?></span>
							<?php if($img_url || $value->value_content_description): ?>
								<div id="tooltip_value_<?php echo $value->value_type_id;?>" class="tooltip">
									<?php if($img_url):?>
										<img src="<?php echo $img_url?>" width="60" height="40"/>
									<?php endif;?>
									<?php echo $value->value_content_description?>
								</div>											
								<script type="text/javascript" >
									$(document).ready(function(){
											$(".view_detail_<?php echo $value->value_type_id;?>").tooltip({
												offset: [10,2],
												effect: 'slide',
												opacity:0.9,
												relative: true,
												tip: "#tooltip_value_<?php echo $value->value_type_id?>"
											}).dynamic({ bottom: { direction: 'down', bounce: true } });
									})
								</script>							
							<?php endif;?>
                        </li>
                        <?php $ii++; endforeach;?>
                    </ul>
                    <?php endif;?>
                <?php endforeach;?>
                <?php if($this->cart_detail):?>
                    <!--Hidden input-->
                    <input type="hidden" value="<?php echo $this->cart_detail->id;?>" name="cart_detail_id" />
                    <div><input type="button" class="add_btn" value="<?php echo $this->translator("shoppingcart_save");?>" rel="edit_attributes"/></div>
                <?php endif;?>
                </form>
            </div>
            <?php else:?>
				<form action="<?php echo $this->url(array('product_id' => $this->product->product_id), 'shoppingcart_shoppingcart_add');?>" method="POST" id="proAttFrom">					
				</form>
			<?php endif;?>
            
            <?php if($product->product_content_description!=""):?>
            <div id="tab2">
				
					<?php
						$product_bundle = $product->product_bundle;
						if($product_bundle == 1):
							$product_product_id_chain = $product->product_product_id_chain;
							$product_product_id_chain = explode(',',trim($product_product_id_chain,','));
							if(count($product_product_id_chain)):
								
								$conn = Tomato_Db_Connection::factory()->getMasterConnection();
								$categoryDao = Tomato_Model_Dao_Factory::getInstance()->setModule('shop')->getCategoryDao();
								$categoryDao->setLang($this->lang);
								$categoryDao->setDbConnection($conn);

								$productDao = Tomato_Model_Dao_Factory::getInstance()->setModule('shop')->getProductDao();
								$productDao->setLang($this->lang);
								$productDao->setDbConnection($conn);
								
								
								$exp    = array('bundle'=>implode(',',$product_product_id_chain));
								$productBundlle = $productDao->find(null,null,$exp);
					?>
					<!-- PRODUCT BUNDLE -->
							<div>
								<?php $i=0; foreach ($productBundlle as $productBundlleItem):
								?>
								<?php
									/**
									* Check image exist directory
									**/
									$strFile = trim($productBundlleItem->product_image,',');
									$arrImage = explode(',', $strFile);									
									$file = $arrImage[0];
									$path = str_replace($this->APP_STATIC_SERVER,getcwd(),$file);
									$file = Tomato_Helper_Helper::checkFile($path, $file, '_small');
									$urlImage = $file?$file:null;
														
														
									/**
									* Category follow product
									**/
									$categoryBundle = $productBundlleItem->category_id;
									$categoryBundle = trim($categoryBundle,',');
									$categoryBundle = explode(',',$categoryBundle);
									if(count($categoryBundle)){
										$categoryBundle = $categoryBundle[0];
										$cat 			= $categoryDao->getById($categoryBundle);
										$cat_id         = $cat->category_id;
										$cat_slug       = Tomato_Utility_String::removeSign($cat->category_admin_name, '-', true);
										
									}
									/**
									* Param url detail
									**/
									$arrRouteDetail = array(
										'enterprise_id' => $this->enterprise->id,
										'enterprise_name' => Tomato_Utility_String::removeSign($this->enterprise->company_name_en, '-', true),
										'cat' => $cat_id,
										'slug' => $cat_slug,
										'product_id' => $productBundlleItem->product_id,
										'pro_slug' => ($productBundlleItem->slug)?$productBundlleItem->slug:Tomato_Utility_String::removeSign($productBundlleItem->product_admin_name, '-', true),
									);
								?>
								<?php if($i%2==0):?>
								<div class="subrow">
								<?php endif;?>
									<div class="col_50">
										<div class="subcolumns_oldgecko">
											<a href="<?php echo $this->url($arrRouteDetail,'shop_product_detail');?>"><span class="title"><?php echo ($productBundlleItem->product_content_name)?$productBundlleItem->product_content_name:$productBundlleItem->product_admin_name;?></span></a>
										</div>
										<div class="subcolumns_oldgecko" style="padding-bottom:5px;">
											<div class="geckol" style="padding-right:5px;">
												<?php if($urlImage):?>
													<a href="<?php echo $this->url($arrRouteDetail,'shop_product_detail');?>"><img class="item_img" width="95" src="<?php echo $urlImage;?>" /></a>
												<?php else:?>
													<a href="<?php echo $this->url($arrRouteDetail,'shop_product_detail');?>"><img class="item_img" src="<?php echo $this->baseUrl(); ?>/skins/bizprofile/default/html/images/img.jpg" /></a>
												<?php endif;?>
											</div>
											<div class="geckor">
												<div style="text-align:justify">
													<?php echo strip_tags(Tomato_Helper_Helper::substring(strip_tags($productBundlleItem->product_content_description), 70));?>
												</div>
											</div>
										</div>
									</div>
								<?php $i++; if($i%2==0):?>
									</div>
								<?php endif;?>
								<?php endforeach;?>
								<?php if($i%2!=0):?>
									</div>
								<?php endif;?>
							</div>			
					<!-- ***************************************************************************************** -->
					<?php endif;
						endif;
					?>
				
                <div style="text-align:justify">
                    <?php echo strip_tags($product->product_content_description);?>
                </div>
            </div>
            <?php endif;?>
            
            <!--San pham lien quan-->
            <?php if(count($this->relatedProducts)>0):?>
				<div id="tab3">
					<?php $i=0; foreach ($this->relatedProducts as $product):?>
					<?php
						/**
						* Check image exist directory
						**/
						$strFile = trim($product->product_image,',');
						$arrImage = explode(',', $strFile);									
						$file = $arrImage[0];												
						$path = str_replace($this->APP_STATIC_SERVER,getcwd(),$file);
						$file = Tomato_Helper_Helper::checkFile($path, $file, '_thumbnail');
						$urlImage = $file?$file:null;
						$r_quantity = null;
						$r_coreQty = null;
						if('non_deliver_able' == $product->product_status_of_delivery){
							$r_quantity = "<span style='color:red;'>".$this->translator("product_status_of_delivery_non_deliverable")."</span>";
							$r_coreQty = $product->product_status_of_delivery;
						}
						elseif('please_contact' == $product->product_status_of_delivery){
							$r_quantity = $this->translator("product_status_of_delivery_".$product->product_status_of_delivery);
							$r_coreQty = $product->product_status_of_delivery;
						}
						else{
							//$quantity = ($product->product_quantity)?$product->product_quantity-$this->qtyItems:"<span style='color:red;'>".$this->translator("product_status_of_delivery_non_deliverable")."</span>";
							$r_quantity = ($product->product_quantity)?$product->product_quantity:"<span style='color:red;'>".$this->translator("product_status_of_delivery_non_deliverable")."</span>";
							$r_coreQty = $product->product_quantity_mode;
						}
											
						
						/**
						* Category follow product
						**/
						$objCategory = $this->arrPC[$product->product_id];

						/**
						* Param url detail
						**/
						$arrRouteDetail = array(
							'enterprise_id' => $this->enterprise->id,
							'enterprise_name' => Tomato_Utility_String::removeSign($this->enterprise->company_name_en, '-', true),
							'cat' => $objCategory->category_id,
							'slug' => ($objCategory->slug)?$objCategory->slug:Tomato_Utility_String::removeSign($objCategory->category_admin_name, '-', true),
							'product_id' => $product->product_id,
							'pro_slug' => ($product->slug)?$product->slug:Tomato_Utility_String::removeSign($product->product_admin_name, '-', true),
						);
					?>
					<?php if($i%2==0):?>
					<div class="subrow">
					<?php endif;?>
						<div class="col_50">
							<div class="subcolumns_oldgecko">
								<a href="<?php echo $this->url($arrRouteDetail,'shop_product_detail');?>"><span class="title"><?php echo ($product->product_content_name)?$product->product_content_name:$product->product_admin_name;?></span></a>
							</div>
							<div class="subcolumns_oldgecko">
								<div class="geckol" style="width:42%;">
									<?php if($product->getImage()):?>
										<a href="<?php echo $this->url($arrRouteDetail,'shop_product_detail');?>">
											<img width="130" src="<?php echo $product->getImage('_small', 200);?>" class="item_img" alt="<?php echo $p_name;?>">
										</a>
									<?php endif;?>
								</div>
								<div class="geckor" style="width: 56%;">
									<div style="text-align:justify">
										<?php echo strip_tags(Tomato_Helper_Helper::substring(strip_tags($product->product_content_description), 70));?>
									</div>
									<div>
										<?php echo $this->translator('front_product_price');?>:
										<strong><?php echo $product->product_price;?> <?php echo $product->product_price_currency;?></strong>
									</div>
									
									<!--Show gia van chuyen va nguon-->                            		
                            		<?php if($product->product_shipping_price_1 > 0):?>
									<div style="width:50%; float:left;">
										<i><?php echo $this->translator('front_product_shipping_price')?></i><br />
										<strong><?php echo $product->product_shipping_price_1;?> <?php echo $product->product_price_currency;?></strong>
									</div>								
									<?php endif;?>
								
									<div style="width:50%; float:left;">
										<?php if($r_coreQty != 'infinity'):?>
										<div style="width:50%; float:left;">
											<?php echo $this->translator('front_product_source')?></i><br />
											<strong id="qtyText"><?php echo $r_quantity;?></strong>
										</div>	
										<?php endif;?>
									</div>								
								</div>
							</div>
						</div>
					<?php $i++; if($i%2==0):?>
					</div>
					<?php endif;?>
					<?php endforeach;?>
					<?php if($i%2!=0):?>
					</div>
					<?php endif;?>
				</div>
            <?php endif;?>
            
            <!-- Hình sản phẩm -->
            <?php if($no_image === false):?>
            <div id="tab4">								
				<div id="product_images"> 	
				<?php foreach($arrImageMain as $image):?>
					<?php 
						$file = $image;
						$path = str_replace($this->APP_STATIC_SERVER,getcwd(),$file);
						$file = Tomato_Helper_Helper::checkFile($path, $file, '_small');
						$file_large = Tomato_Helper_Helper::checkFile($path, $file, '_large');
						$urlImage = $file?$file:null;
					?>
					<?php if($urlImage):?>
						<div style="float:left; width:30%; margin:5px; height:150px; overflow:hidden;"><a href="<?php echo $file_large;?>"><img width="190" src="<?php echo $urlImage;?>" /></a></div>
					<?php endif;?>					
				<?php endforeach;?>
				</div>				
            </div>
            <?php endif;?>
        </div>
        <input type="hidden" value="<?php echo $this->product->product_quantity-$this->qtyItems;?>" id="oldQty" />
        <!--end tab-->
        <script type="text/javascript" src="<?php echo $this->APP_STATIC_SERVER; ?>/js/jquery.form/jquery.form.js"></script>
        <script type="text/javascript" charset="utf-8">
        
        $(function () {
			var tabContainers = $('div.tabs > div');
			tabContainers.hide().filter(':first').show();

			$('div.tabs ul.tabNavigation a').click(function () {
					tabContainers.hide();
					tabContainers.filter(this.hash).show();
					$('div.tabs ul.tabNavigation a').removeClass('selected');
					$(this).addClass('selected');
					return false;
			}).filter(':first').click();
			
			/**
			* Lightbox
			**/
			$('#product_images a').lightBox();
		});        
        
        $(document).ready(function() {
            /**
            * Ajax submit form
            */
            $('.add_btn').click(function(){
				var has_attr  = $(this).hasClass('has_attr');
                var self = this;
                var p_qty = '<?php echo $this->product->product_quantity;?>';
				var quantity = $('#quantity').val();
				var rel      = $(self).attr("rel"); //
				if(quantity <= 0){
					quantity = 1;
				}
				var is_update_attr  =  (rel == "edit_attributes");	
				if(is_update_attr){
					$("#proAttFrom").ajaxSubmit(options);
				}else if(IsNumeric(quantity)){					
					
	                $(self).html('').addClass('t_a_ui_helper_loading');
	                var options = {
	                    target: '#outPut', // target element(s) to be updated with server response
	                    beforeSubmit:  showRequest,
	                    url: '<?php echo $this->url(array('product_id' => $this->product->product_id), 'shoppingcart_shoppingcart_add');?>',
	                    data: {quantity : quantity},
	                    type: 'POST',  // pre-submit callback,
	                    dataType: 'html',
	                    success: function(responseText, statusText){
	                        $(self).removeClass('t_a_ui_helper_loading')
	                        .append($('<img style="cursor:pointer;" src="<?php echo $skin_url;?>/html/images/icon-cart.png" />').html(''));
	                        
	                        /**
	                        * Update num cart item
	                        */
	                        num_cartItem = $('#num_cartItem').text();		                        
	                        num_cartItem = parseInt(num_cartItem)+1;
	                        $('#num_cartItem').text(num_cartItem);
							if(has_attr == false){
		                            $('#messageDialog').html('<?php echo $this->translator('shoppingcart_message_success');?>')
		                            .dialog({
		                                title: '<?php echo addslashes($this->translator('common_dialog_message')); ?>',
		                                dialogClass: 't_a_ui_dialog',
		                                modal: true,
		                                show: { effect: 'fade' },
		                                open: function(event, ui) {
											
		                                },
		                                close: function(event, ui){
		                                    $('#' + event.target.id).dialog('option', 'hide', 'fade').dialog('destroy');
		                                }
		                            });
							}
	                    }
                	};	                	
                	$("#proAttFrom").ajaxSubmit(options);
				}
				else{				
					$('#quantity').focus();				
				}
                
            });
            
            $('#quantity').keyup(function() {		
				var p_qty = $("#oldQty").val();
				var quantity = $('#quantity').val();
				
				if(IsNumeric(quantity)){
					$('#quantity').focus();
					$("#alert_message").text("");
					
					if(quantity <= parseInt(p_qty) || '<?php echo $this->product->product_quantity_mode?>' == 'infinity'){					
						$('#quantity').focus();
						$("#alert_message").text("");
					}
				}else{
					$('#quantity').focus();
					$("#alert_message").text("<?php echo $this->translator('product_detail_no_num_message');?>");				
				}
			});
            
        })
        function showRequest(formData, jqForm, options) {        	
            var queryString = $.param(formData);
            return true;
        }
        function IsNumeric(sText)
		{
		   if(sText == 'undefined') return false;
		   var ValidChars = "0123456789.";
		   var IsNumber=true;
		   var Char;	 
		   for (i = 0; i < sText.length && IsNumber == true; i++) 
			{ 
			  Char = sText.charAt(i); 
			  if (ValidChars.indexOf(Char) == -1) 
				{
					IsNumber = false;
				}
			}
		   return IsNumber;	   
		}
        </script>
        <?php endif;?>
    </div>
    <div class="grid_4 omega">
        <?php echo $this->widget('bizprofile','map',array()); ?>
        <?php echo $this->widget('bizprofile','help',array()); ?>
    </div>
</div>
<div class="grid_12">
    <?php echo $this->widget('bizprofile','contact',array()); ?>
</div>